<?php
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

/**
 * osapiXrdsProvider test case.
 */
class osapiXrdsProviderTest extends PHPUnit_Framework_TestCase {
  
  /**
   * Tests osapiXrdsProvider->__construct()
   */
  public function test__construct() {
    $xrds = file_get_contents(realpath(dirname(__FILE__) . "/xrdsTestData.xml"));
    
    $httpProvider = new osapiLocalHttpProvider();
    $httpProvider->addResponse("somecontent", 200, array("X-XRDS-Location" => "http://www.partuza.nl/xrds"));
    $httpProvider->addResponse($xrds, 200);

    $storage = new osapiFileStorage("/tmp/osapi");
    $url = "http://www.partuza.nl";
    
    $requestTokenUrl = "http://www.partuza.nl/oauth/request_token";
    $authorizeUrl = "http://www.partuza.nl/oauth/authorize";
    $accessTokenUrl = "http://www.partuza.nl/oauth/access_token";
    $restEndpoint = "http://modules.partuza.nl/social/rest";
    $rpcEndpoint = "http://modules.partuza.nl/social/rpc";
    
    $xrdsProvider = new osapiXrdsProvider($url, $storage, $httpProvider);
    
    $this->assertEquals($requestTokenUrl, $xrdsProvider->requestTokenUrl);
    $this->assertEquals($authorizeUrl, $xrdsProvider->authorizeUrl);
    $this->assertEquals($accessTokenUrl, $xrdsProvider->accessTokenUrl);
    $this->assertEquals($restEndpoint, $xrdsProvider->restEndpoint);
    $this->assertEquals($rpcEndpoint, $xrdsProvider->rpcEndpoint);
    
    $storage->delete($url . ":xrds");
  }
}
